package com.woniuxy.main.provider;

import com.woniuxy.main.pojo.Staff;
import org.apache.ibatis.jdbc.SQL;


public class StaffProvider {

    public String provideSql(Staff staff) {

        SQL sql = new SQL().SELECT("*").FROM("staff").WHERE("flag=0");

        //工号
        if (staff.getStaff_id() != null) {
            sql.WHERE("staff_id = " + staff.getStaff_id());
        }
        //姓名
        if (staff.getSname() != null && staff.getSname().length() != 0) {
            sql.WHERE("sname like '%" + staff.getSname() + "%'");
        }
        //部门
        if (staff.getDepartment_id() != null) {
            sql.WHERE("department_id =" + staff.getDepartment_id());
        }
        //职务
        if (staff.getRole_id() != null) {
            sql.WHERE("role_id = " + staff.getRole_id());
        }
        //电话
        if (staff.getSphone() != null && staff.getSphone().length() != 0) {
            sql.WHERE("sphone like '%" + staff.getSphone() + "%'");
    }
        return sql.toString();

    }

}
